package com.first.wchat;

import com.first.wchat.data.MSGDataManager;
import com.wchat.network.Controller;
import com.wchat.network.UserAction;

import android.app.TabActivity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.TabHost;

public class MainActivity extends TabActivity {

	
	static UserAction mActionFactory;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.tabs);
        
        mActionFactory = Controller.getInstance();
		Controller.getInstance().start(this);
		MSGDataManager.getInstance().init(this);
		TabHost tabHost = (TabHost) findViewById(android.R.id.tabhost);
		tabHost.addTab(tabHost
				.newTabSpec("1")
				.setIndicator(getText(R.string.tab_users),
						getResources().getDrawable(R.drawable.icon))
				.setContent(new Intent(this, WChatActivity.class)));

		tabHost.addTab(tabHost
				.newTabSpec("2")
				.setIndicator(getText(R.string.tab_broadcast),
						getResources().getDrawable(R.drawable.icon))
				.setContent(new Intent(this, BroadcastActivity.class)));

		tabHost.addTab(tabHost
				.newTabSpec("3")
				.setIndicator(getText(R.string.tab_groups),
						getResources().getDrawable(R.drawable.icon))
				.setContent(new Intent(this, GroupActivity.class)));
	}
	
	
	protected void onDestroy()
	{
		MSGDataManager.getInstance().release();
		Controller.getInstance().stop();
		super.onDestroy();
	}
	
	public static UserAction getUserAction()
	{
		return mActionFactory;
	}
}
